package rad.framework.mda.generator.template.main.webapp;

import org.eclipse.uml2.uml.Class;
import org.eclipse.uml2.uml.*;
import java.util.*;
import rad.framework.mda.generator.util.*;

public class ViewPanel
{
  protected static String nl;
  public static synchronized ViewPanel create(String lineSeparator)
  {
    nl = lineSeparator;
    ViewPanel result = new ViewPanel();
    nl = null;
    return result;
  }

  public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
  protected final String TEXT_1 = "<ui:composition " + NL + "\txmlns=\"http://www.w3.org/1999/xhtml\"" + NL + "\txmlns:ui=\"http://java.sun.com/jsf/facelets\"" + NL + "\txmlns:tt=\"https://code.google.com/p/rad-framework\">" + NL + "\t" + NL + "\t<tt:attributes>";
  protected final String TEXT_2 = NL;
  protected final String TEXT_3 = NL + "\t<ui:remove>";
  protected final String TEXT_4 = NL + "\t\t<tt:output type=\"";
  protected final String TEXT_5 = "\" id=\"";
  protected final String TEXT_6 = "\" " + NL + "\t\t\tvalue=\"#{entity.";
  protected final String TEXT_7 = "}\"" + NL + "\t\t\tlabel=\"#{messages['";
  protected final String TEXT_8 = "_";
  protected final String TEXT_9 = "']}\"" + NL + "\t\t\ttitle=\"#{messages['";
  protected final String TEXT_10 = "_";
  protected final String TEXT_11 = "Doc']}\"\t/>";
  protected final String TEXT_12 = NL + "\t</ui:remove>";
  protected final String TEXT_13 = NL + NL + "\t\t<tt:reference-output type=\"";
  protected final String TEXT_14 = "\" id=\"";
  protected final String TEXT_15 = "\" " + NL + "\t\t\treference=\"#{entity.";
  protected final String TEXT_16 = "}\"" + NL + "\t\t\tkey=\"#{entity.";
  protected final String TEXT_17 = ".id}\"\t\t\t" + NL + "\t\t\tvalue=\"#{";
  protected final String TEXT_18 = "ComboBox.getLabel(entity.";
  protected final String TEXT_19 = ")}\" " + NL + "\t\t\tlabel=\"#{messages['";
  protected final String TEXT_20 = "_";
  protected final String TEXT_21 = "']}\"" + NL + "\t\t\ttitle=\"#{messages['";
  protected final String TEXT_22 = "_";
  protected final String TEXT_23 = "Doc']}\"\t/>";
  protected final String TEXT_24 = NL + NL + "\t\t<ui:define name=\"footer\">";
  protected final String TEXT_25 = NL + "\t\t\t<tt:output type=\"";
  protected final String TEXT_26 = "\" id=\"";
  protected final String TEXT_27 = "\" " + NL + "\t\t\t\tvalue=\"#{entity.";
  protected final String TEXT_28 = "}\"" + NL + "\t\t\t\tlabel=\"#{messages['";
  protected final String TEXT_29 = "_";
  protected final String TEXT_30 = "']}\"" + NL + "\t\t\t\ttitle=\"#{messages['";
  protected final String TEXT_31 = "_";
  protected final String TEXT_32 = "Doc']}\"\t/>";
  protected final String TEXT_33 = NL + "\t\t</ui:define>" + NL + "\t</tt:attributes>";
  protected final String TEXT_34 = NL + NL + "\t<tt:embedded-output type=\"";
  protected final String TEXT_35 = "\" id=\"";
  protected final String TEXT_36 = "\" " + NL + "\t\tvalue=\"#{entity.";
  protected final String TEXT_37 = "}\"" + NL + "\t\tlabel=\"#{messages['";
  protected final String TEXT_38 = "_";
  protected final String TEXT_39 = "']}\"" + NL + "\t\ttitle=\"#{messages['";
  protected final String TEXT_40 = "_";
  protected final String TEXT_41 = "Doc']}\"\t/>";
  protected final String TEXT_42 = NL + NL + "</ui:composition>";
  protected final String TEXT_43 = NL;

  public String generate(Object argument)
  {
    final StringBuffer stringBuffer = new StringBuffer();
    

    Class uml2Class = (Class) argument;
    String capClassName = NameHelper.getCapName(uml2Class);
    stringBuffer.append(TEXT_1);
    for (Iterator<Property> i=ClassHelper.getAllSimpleProperties(uml2Class); i.hasNext();) { Property property = i.next();
    if (!TypeHelper.isText(property)) {
    stringBuffer.append(TEXT_2);
    if (StereotypeHelper.isStereotypeApplied(property, StereotypeHelper.GENERATED_VALUE)) {
    stringBuffer.append(TEXT_3);
    }
    stringBuffer.append(TEXT_4);
    stringBuffer.append(JsfHelper.getType(property));
    stringBuffer.append(TEXT_5);
    stringBuffer.append(property.getName());
    stringBuffer.append(TEXT_6);
    stringBuffer.append(property.getName());
    stringBuffer.append(TEXT_7);
    stringBuffer.append(capClassName);
    stringBuffer.append(TEXT_8);
    stringBuffer.append(property.getName());
    stringBuffer.append(TEXT_9);
    stringBuffer.append(capClassName);
    stringBuffer.append(TEXT_10);
    stringBuffer.append(property.getName());
    stringBuffer.append(TEXT_11);
    if (StereotypeHelper.isStereotypeApplied(property, StereotypeHelper.GENERATED_VALUE)) {
    stringBuffer.append(TEXT_12);
    }}}
    for (Iterator<Property> i=ClassHelper.getAllManyToOneProperties(uml2Class); i.hasNext();) { Property property = i.next();
    if (StereotypeHelper.isStereotypeApplied(property, StereotypeHelper.M2O) && !ClassHelper.isMyParent(property)) {
    stringBuffer.append(TEXT_13);
    stringBuffer.append(property.getType().getName());
    stringBuffer.append(TEXT_14);
    stringBuffer.append(property.getName());
    stringBuffer.append(TEXT_15);
    stringBuffer.append(property.getName());
    stringBuffer.append(TEXT_16);
    stringBuffer.append(property.getName());
    stringBuffer.append(TEXT_17);
    stringBuffer.append(property.getName());
    stringBuffer.append(TEXT_18);
    stringBuffer.append(property.getName());
    stringBuffer.append(TEXT_19);
    stringBuffer.append(capClassName);
    stringBuffer.append(TEXT_20);
    stringBuffer.append(property.getName());
    stringBuffer.append(TEXT_21);
    stringBuffer.append(capClassName);
    stringBuffer.append(TEXT_22);
    stringBuffer.append(property.getName());
    stringBuffer.append(TEXT_23);
    }}
    stringBuffer.append(TEXT_24);
    for (Iterator<Property> i=ClassHelper.getAllSimpleProperties(uml2Class); i.hasNext();) { Property property = i.next();
    if (TypeHelper.isText(property)) {
    stringBuffer.append(TEXT_25);
    stringBuffer.append(JsfHelper.getType(property));
    stringBuffer.append(TEXT_26);
    stringBuffer.append(property.getName());
    stringBuffer.append(TEXT_27);
    stringBuffer.append(property.getName());
    stringBuffer.append(TEXT_28);
    stringBuffer.append(capClassName);
    stringBuffer.append(TEXT_29);
    stringBuffer.append(property.getName());
    stringBuffer.append(TEXT_30);
    stringBuffer.append(capClassName);
    stringBuffer.append(TEXT_31);
    stringBuffer.append(property.getName());
    stringBuffer.append(TEXT_32);
    }}
    stringBuffer.append(TEXT_33);
    for (Iterator<Property> i=ClassHelper.getCompositeProperties(uml2Class); i.hasNext();) { Property property = i.next();
    stringBuffer.append(TEXT_34);
    stringBuffer.append(property.getType().getName());
    stringBuffer.append(TEXT_35);
    stringBuffer.append(property.getName());
    stringBuffer.append(TEXT_36);
    stringBuffer.append(property.getName());
    stringBuffer.append(TEXT_37);
    stringBuffer.append(capClassName);
    stringBuffer.append(TEXT_38);
    stringBuffer.append(property.getName());
    stringBuffer.append(TEXT_39);
    stringBuffer.append(capClassName);
    stringBuffer.append(TEXT_40);
    stringBuffer.append(property.getName());
    stringBuffer.append(TEXT_41);
    }
    stringBuffer.append(TEXT_42);
    stringBuffer.append(TEXT_43);
    return stringBuffer.toString();
  }
}
